#ifndef AVALON_TIMER_HPP
#define AVALON_TIMER_HPP
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/function.hpp>
#include <boost/noncopyable.hpp>
#include "Avalon/Base/Out.hpp"
#include "Avalon/Threading/Threading.hpp"

namespace Avalon {
namespace Threading {

  /*! \class Timer
   *  \brief Emits a signal after a specified period of time.
   */
  class Timer : private boost::noncopyable {
    public:

      //! Called when a Timer's interval expired.
      typedef boost::function<void ()> ExpiredSlot;

      virtual ~Timer();

      //! Starts the Timer.
      virtual void Start() = 0;

      //! Cancels the Timer.
      /*!
        \param expired <code>true</code> iff the Timer expired prior to being
                       cancelled.
      */
      virtual void Cancel(Out<bool> expired) = 0;

      //! Sets the ExpiredSlot.
      /*!
        \param slot The slot to connect.
      */
      virtual void SetExpiredSlot(const ExpiredSlot& slot) = 0;
  };
}
}

#endif // AVALON_TIMER_HPP
